home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 23
/
Amiga Format AFCD23 (Feb 1998, Issue 107).iso
/
-in_the_mag-
/
emulation
/
consoles
/
amigavgb
/
gb.h
< prev
next >
Wrap
C/C++ Source or Header
|
1997-12-12
|
7KB
|
141 lines
/** VGB: portable GameBoy emulator ***************************/
/** **/
/** GB.h **/
/** **/
/** This file contains definitions for the GameBoy hardware **/
/** emulation. **/
/** **/
/** Copyright (C) Marat Fayzullin 1995 **/
/** You are not allowed to distribute this software **/
/** commercially. Please, notify me, if you make any **/
/** changes to this file. **/
/*************************************************************/
#include "Z80.h" /* CPU emulation declarations */
/* #define UNIX */ /* Compile iNES for for Unix/X */
/* #define MSDOS */ /* Compile iNES for MSDOS/VGA */
/* #define MITSHM */ /* Use MIT SHM extensions for X */
#ifndef UNIX
#undef MITSHM
#endif
#define NORAM 0x00 /* Byte to be returned from */
/* non-existing pages and ports */
#define MAXCHEAT 256 /* Maximal number of GG cheats */
#define VBL_IFLAG 0x01
#define LCD_IFLAG 0x02
#define TIM_IFLAG 0x04
#define SIO_IFLAG 0x08
#define EXT_IFLAG 0x10
#define JOYPAD RAM[0xFF00] /* Joystick: 1.1.P15.P14.P13.P12.P11.P10 */
#define SIODATA RAM[0xFF01] /* Serial IO data buffer */
#define SIOCONT RAM[0xFF02] /* Serial IO control register */
#define DIVREG RAM[0xFF04] /* Divider register (???) */
#define TIMECNT RAM[0xFF05] /* Timer counter. Gen. int. when it overflows */
#define TIMEMOD RAM[0xFF06] /* New value of TimeCount after it overflows */
#define TIMEFRQ RAM[0xFF07] /* Timer frequency and start/stop switch */
#define IFLAGS RAM[0xFF0F] /* Interrupt flags: 0.0.0.JST.SIO.TIM.LCD.VBL */
#define ISWITCH RAM[0xFFFF] /* Switches to enable/disable interrupts */
#define LCDCONT RAM[0xFF40] /* LCD control register */
#define LCDSTAT RAM[0xFF41] /* LCD status register */
#define SCROLLY RAM[0xFF42] /* Starting Y position of the background */
#define SCROLLX RAM[0xFF43] /* Starting X position of the background */
#define CURLINE RAM[0xFF44] /* Current screen line being scanned */
#define CMPLINE RAM[0xFF45] /* Gen. int. when scan reaches this line */
#define BGRDPAL RAM[0xFF47] /* Background palette */
#define SPR0PAL RAM[0xFF48] /* Sprite palette #0 */
#define SPR1PAL RAM[0xFF49] /* Sprite palette #1 */
#define WNDPOSY RAM[0xFF4A] /* Window Y position */
#define WNDPOSX RAM[0xFF4B] /* Window X position */
extern byte Verbose; /* Verboseness level */
extern byte *RAM; /* Pointer to Z80 address space (64kB) */
extern byte UPeriod; /* Number of VBlanks per screen update */
extern int VPeriod; /* Number of Z80 cycles between VBlanks */
extern byte LineDelay; /* When 1, CMPLINE interrupts are delayed */
extern byte CheckCRC; /* When 1, check cartridge CRC on loading */
extern byte AutoA,AutoB; /* When 1, autofire emulation for A,B */
extern char *SndName; /* Name for the soundtrack log file */
extern int CheatCount; /* Current number of cheats in the list */
extern byte BPal[4]; /* Background palette */
extern byte SPal0[4],SPal1[4];/* Sprite palettes */
extern byte *ChrGen; /* Character generator */
extern byte *BgdTab,*WndTab; /* Background and window character tables */
extern byte IMask; /* A mask to reset a bit in IFLAGS */
/****************************************************************/
/*** Initialize and start GameBoy emulation. This function ***/
/*** returns 0 in the case of failure. ***/
/****************************************************************/
int StartGB(char *CartName);
/****************************************************************/
/*** Free resources allocated by StartGB(). ***/
/****************************************************************/
void TrashGB(void);
/****************************************************************/
/*** Add a cheat to the cheat list [call before StartGB()]. ***/
/****************************************************************/
int AddCheat(char *Cheat);
/****************************************************************/
/*** Allocate resources needed by the machine-dependent code. ***/
/************************************** TO BE WRITTEN BY USER ***/
int InitMachine(void);
/****************************************************************/
/*** Deallocate all resources taken by InitMachine(). ***/
/************************************** TO BE WRITTEN BY USER ***/
void TrashMachine(void);
/****************************************************************/
/*** Refresh screen. ***/
/************************************** TO BE WRITTEN BY USER ***/
void RefreshScreen(void);
/****************************************************************/
/*** Refresh line Y [0-143]. ***/
/************************************** TO BE WRITTEN BY USER ***/
void RefreshLine(byte Y);
/****************************************************************/
/*** Refresh sprites. ***/
/************************************** TO BE WRITTEN BY USER ***/
void RefreshSprites(void);
/****************************************************************/
/*** Get joystick state: START.SELECT.B.A.D.U.L.R. ***/
/************************************** TO BE WRITTEN BY USER ***/
byte Joystick(void);
/****************************************************************/
/*** Write value into sound chip register (Reg #0 at FF10h). ***/
/************************************** TO BE WRITTEN BY USER ***/
void Sound(byte R,byte V);
/****************************************************************/
/*** Send a byte onto the serial line. Returns 1 on success, ***/
/*** 0 otherwise. ***/
/************************************** TO BE WRITTEN BY USER ***/
byte SIOSend(byte V);
/****************************************************************/
/*** Receive a byte from the serial line. Returns 1 on ***/
/*** success, 0 otherwise. ***/
/************************************** TO BE WRITTEN BY USER ***/
byte SIOReceive(byte *V);